#pragma once

#include <string>
#include <QThread>
#include <Oak.h>
#include "utils/circularbuffer.h"
using namespace std;

class OakSensorVisual: QThread
{
public:
	enum LedModeEnum{
		OFF=0x00,
		ON=0x01,
		BLINKSLOWLY=0x02,
		BLINKFAST=0x03,
		BLINK4PULSES=0x04
	};

	enum ReportModeEnum{
		FIXED,
		AFTERSAMPLING,
		AFTERCHANGE
	};

	OakSensorVisual(const string &_serialNumber="");
	virtual ~OakSensorVisual(void);
	void setLedMode(LedModeEnum _newMode);
	void setReportMode(ReportModeEnum _newMode);
	void setSampleRateMs(int _rateMs);
	void setReportRate(int _rateMs);

	bool startCapture();
	void run();
	void stop();

	/// Returns an array of data
    /// @param channel The sensors channel
    /// @param array A pointer to the array that will be filled with the sensor data
    /// @param size The maximal size of the array
    /// @param newOnly True for getting only the last values that have not been read since last call
    /// @return The number of values written in the array
    int getBufferArray(int channel, short* array, int size, bool newOnly = false);

private:
	bool m_isOpen;
	tOakSensor m_sensor;
	HANDLE m_handle;
	int     m_iChannels;
	CircularBuffer*     m_pBuffers;
	bool    m_bContinue;
	
};

